Dynamic HTML (DHTML) attached behaviors are simple, lightweight components that encapsulate specific functionality or behavior on a page. When applied to a standard HTML element on a page, a DHTML behavior component enhances that element's default behavior. For example, an attached behavior component can be created that toggles the display property of an element's children on a mouse click. When this attached behavior component is applied to a standard unordered list (UL) element on a page, it enhances the unordered list element's default behavior to expand and collapse when clicked. Similarly, another attached behavior component can incrementally set the position of an element from a start point to an end point on the screen, whereby if such a behavior component is applied to an image element, the otherwise statically positioned image “flies” across the screen.
DHTML attached behaviors add great value to a Web application environment, making things easier for everyone involved in the Web development process. Typically, this environment consists of a team of content designers, designers, and developers. Content designers are responsible for writing content. Designers determine what interactive effects can be added to the content, while developers implement those effects. Prior to DHTML behaviors, the task of adding interactive effects to a page involved a lengthy iterative process between the designer and the developer trying to give the page the proper look. The designer, usually with limited programming background, mocked up the desired effect on the content in a desktop publishing environment, and worked closely with the developer to achieve the same effect on the page, usually with scripts.
With DHMTL attached behaviors, a developer can work independently on encapsulating the desired effect in a separate behavior component file, while the designer applies that attached behavior component to elements on the page with a few attributes. By providing a simple declarative syntax, requiring no prerequisite knowledge of scripting and DHTML, DHTML behavior components empower Web designers to easily add interactive effects to an otherwise static content.
DHTML attached behaviors were introduced in Microsoft® Internet Explorer 5.0 product, and are described in U.S. patent application Ser. No. 09/316,897, entitled as “Dynamic Web Page Behavior,” owned by the assignee of the present disclosure, and incorporated herein by reference. With attached behaviors, behavior components are attached to Cascading Style Sheet (CSS) elements and modify their behavior. Attached behaviors bind asynchronously to the elements that they affect, and can be attached or removed from an element programmatically.
One problem with attached behaviors is that a Web designer revising the CSS may inadvertently detach an attached behavior component from the element that it is modifying. Alternatively, a Web designer revising the CSS may detach an attached behavior component from the element it is modifying by calling the removeBehavior method in script. Such removal may have an adverse effect on some of the existing document, which may not be readily apparent to the Web designer. In addition, an attached behavior is affected by the CSS style of the element to which it is attached, so the appearance of the element may be different from what the behavior designer intended as a result of CSS inheritance. Finally, attached behaviors are often unpredictable in the asynchronous parsing of a document, because attached behaviors are sometimes not instantiated at the time dependent elements try to access them.